// pages/contract/contract.js
var util = require('../../utils/util.js')
var common = require('../../utils/common.js');
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    roomId: "",
    memberId: "",
    phone: "",//电话号码
    houseList: [],//房源列表
    houseIndex: 0,//房源列表下标
    roomList: [],//房间列表
    roomIndex: 0,//房间列表下标
    thatTime: "",//当前日期用于时间选择
    startTime: "",//合同开始时间
    endTime: "",//合同结束时间
    month: "",//相差月数
    dateSelectTab: [{ value: "3个月", y: 0, m: 3, check: false }, { value: "6个月", y: 0, m: 6, check: false }, { value: "1年", y: 1, m: 0, check: false }, { value: "2年", y: 2, m: 0, check: false }, { value: "3年", y: 3, m: 0, check: false }],
    payTypeList: [],//付款方式列表
    paytypeindex: 0,//付款方式下标
    cardImag: "",//身份证正面
    cardImagUrl: "",//正面路径
    cardBack: "",//身份证反面
    cardBackUrl: "",//反面路径
    cardInfo: {},//身份信息
    feeList: [{ id: '', pid: 1, sequence: 12, itemKey: "12", itemName: "水费", chargeType: 0, nowNum: 0, unitCost: 0 }, { id: '', pid: 1, sequence: 6, itemKey: "6", itemName: "电费", chargeType: 0, nowNum: 0, unitCost: 0 }],//费用项目列表
    feeListy: [{ chargeType: 1, checked: true, id: "", itemKey: "1", itemName: "房屋押金", pid: 33, sequence: 1, unitCost: "", }],//押金费用项目列表
    feeItemType: "CHARGEITEM",//费用项类型 费用项（CHARGEITEM）、押金项（FOREGIFT）
    signatureUrl: "",// 签名图片路径 目前暂时不用签名
    checked: false,//相关协议
    // 0--女 1--男
    sexList: [{ sex: 1, sex_cn: '男' }, { sex: 0, sex_cn: '女' }],
    sexIndex: 0,
    WEmodal: true,//水电输入弹窗
    WEItem: {},//弹窗数据对象
    WEItemIndex: 0,//水电点击下标
    total: 0,//总计
    monthlyfee: 0,
  },

  initData: function () {
    var that = this;
    //付款方式
    common._get('/wx/dict/list', { key: 'CHARGEMODE' },
      //成功
      function (res) {
        if (res.data.success) {
          that.setData({
            payTypeList: res.data.data,
          })
        }
      });
    if (this.data.roomId == "") {
      console.log('0000000')
      //获取房源
      common._get('/wx/house/houselist', { page: '1' },
        //成功
        function (res) {
          if (res.data.success) {
            var houses = []
            for (var i in res.data.data.list) {
              //房源
              var house = { id: res.data.data.list[i].houseId, name: res.data.data.list[i].houseName };
              houses.push(house)
            }
            console.log(houses)
            that.setData({
              houseList: houses,
            })
            that.getRoomList(that.data.houseList[0].id)
          }
        });

    } else {

      //获取数据
      common._get('/wx/room/getroominfo', { roomId: this.data.roomId },
        //成功
        function (res) {
          // console.log(res.data);
          if (res.data.success) {
            //房源
            var house = [{ id: res.data.data.houseId, name: res.data.data.houseName }];
            //房间
            var room = [{ id: res.data.data.id, roomcode: res.data.data.roomcode, house_type_name: res.data.data.houseTypeValue }];
            that.setData({
              houseList: house,
              roomList: room,
              paytypeindex: res.data.data.chargemode - 1,//付款方式下标
              monthlyfee: res.data.data.price
            })
            that.countYj();
            that.totalFun();

            // //设置标题
            // wx.setNavigationBarTitle({
            //   title: that.data.data.houseName + '-' + that.data.data.roomcode,
            // })

          }
        });
    }
    that.setData({
      thatTime: util.formatTimeYear(new Date, 0, 0),
      startTime: util.formatTimeYear(new Date, 0, 0),
      endTime: util.formatTimeYear(new Date(), 1, 0, 1),
    })
  },

  //根据房子id获取房间列表
  getRoomList: function (houseId) {
    var that = this;
    //获取房间列表
    common._get('/wx/house/roomlist', { houseId: houseId, status: 0 },
      //成功
      function (res) {
        if (res.data.success) {
          console.log(res.data);
          var rooms = []
          for (var i in res.data.data.list) {
            //房间
            var room = { id: res.data.data.list[i].id, roomcode: res.data.data.list[i].roomcode, house_type_name: res.data.data.list[i].house_type_name, monthlyfee: res.data.data.list[i].monthlyfee };
            rooms.push(room)
          }
          console.log(rooms)
          that.setData({
            roomList: rooms,
            monthlyfee: rooms[0].monthlyfee,
          })
          that.countYj();
          that.totalFun();
        }
      });
  },

  //开始时间选择
  startTimeChange: function (e) {
    this.setData({
      startTime: e.detail.value
    })
    this.setMonth();
  },
  //结束时间选择
  endTimeChange: function (e) {
    this.setData({
      endTime: e.detail.value
    })
    this.setMonth();
  },
  //时间项选择
  timeItemClick: function (e) {
    var index = e.currentTarget.dataset.index;
    var obj = this.data.dateSelectTab[index];
    var date1 = this.data.startTime.split("-");
    this.setData({
      endTime: util.formatTimeYear(new Date(date1[0], date1[1] - 1, date1[2]), obj.y, obj.m, 1),
    })
    this.setMonth();
  },
  //设置相差月数
  setMonth: function () {
    var m = common.getMonths(this.data.startTime, this.data.endTime);
    this.setData({
      month: m
    })
  },
  //电话号码输入框
  phoneChange: function (e) {
    this.setData({
      phone: e.detail.value
    })
  },

  //电话获取用户信息
  gerUserByPhone: function () {
    var that = this;
    if (!this.data.phone.length > 0) {
      wx.showModal({
        title: '提示',
        content: '请先输入联系电话来识别用户',
        showCancel: false,
      })
      return;
    }
    if (!common.checkMobile(this.data.phone)) {
      wx.showModal({
        title: '提示',
        content: '请输入正确的电话号码',
        showCancel: false,
      })
      return;
    }
    //获取数据
    common._get('/wx/user/checkMember', { mobile: this.data.phone },
      //成功
      function (res) {
        console.log(res.data);
        //手机获取信息是否成功
        if (res.data.success) {
          var user = { id: res.data.data.id, name: res.data.data.username, sex: res.data.data.sex, num: res.data.data.idnumber }
          if (res.data.data.sex == 0) {
            res.data.data.sex = 1
          } else {
            res.data.data.sex = 0
          }
          that.setData({
            cardInfo: user,
            phone: res.data.data.mobile,
            memberId: res.data.data.memberId,
            sexIndex: res.data.data.sex,
          })
          if (res.data.data.idCardFace && res.data.data.idCardFace != null && res.data.data.idCardFace != "") {
            that.setData({
              cardImagUrl: res.data.data.idCardFace,
            })
          }
          if (res.data.data.idCardBack && res.data.data.idCardBack != null && res.data.data.idCardBack != "") {
            that.setData({
              cardBackUrl: res.data.data.idCardFace,
            })
          }
        } else {
          console.log(that.data.cardImag + 'sssssssssssss')
          //判断是否已经添加身份证正面图片
          if (that.data.cardImag && that.data.cardImag.length > 0 && that.data.cardImag != null && that.data.cardImag != "") {
            that.getUserInfoByCardImg();
          } else {
            wx.showModal({
              title: '提示',
              content: '手机号码无法获取用户信息，是否要使用是身份证图片来识别用户并信息自动填写',
              success: function (res) {
                //点击确定打开相机或者图片选择图片
                if (res.confirm) {
                  wx.chooseImage({
                    count: 1, // 默认9
                    sizeType: ['compressed'], // 可以指定是原图还是压缩图，默认二者都有
                    sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
                    success: function (res) {
                      // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
                      var tempFilePaths = res.tempFilePaths
                      that.setData({
                        cardImag: res.tempFilePaths
                      });
                      that.getUserInfoByCardImg();
                    }
                  })


                } else if (res.cancel) {
                  console.log('用户点击取消')
                }
              }
            })
          }

        }
      });
  },

  //根据身份证图片获取用户信息 
  getUserInfoByCardImg: function () {
    var that = this;
    common._upload_file('/wx/contract/savepic', that.data.cardImag[0], 'file', { attribute: 'face' },
      //成功
      function (res) {
        if (res.success) {
          console.log(res)
          var sex = 1;
          if (res.data.sex_cn == '男') {
            sex = 0;
          } else {
            sex = 1;
          }
          that.setData({
            cardInfo: res.data,
            sexIndex: sex,
            cardImagUrl: res.data.imgUrl,
          });

          wx.showToast({
            title: '识别成功',
          })
          console.log(that.data.cardInfo);
        }
      });
  },
  //点击相机照片提示
  cameraImgClick: function () {
    wx.showModal({
      title: '提示',
      content: '点击下方灰色框选择，红色边框为身份证正面照，另一个为反面',
      showCancel: false,
    })
  },

  //选择图片或者查看图片 
  caedＯrc: function (e) {
    var cardiszf = e.target.dataset.iszf;
    //是正面还是反面
    if (cardiszf == "true") {
      // 添加或者查看
      if (this.data.cardImag.length > 0) {
        wx.previewImage({
          current: 0, // 当前显示图片的http链接
          urls: this.data.cardImag // 需要预览的图片http链接列表
        })
      } else {
        this.caedFaceImgClick(e);
      }
    } else {
      if (this.data.cardBack.length > 0) {
        wx.previewImage({
          current: 0, // 当前显示图片的http链接
          urls: this.data.cardBack // 需要预览的图片http链接列表
        })
      } else {
        this.caedFaceImgClick(e);
      }
    }

  },
  //选择身份证
  caedFaceImgClick: function (e) {
    var cardiszf = e.target.dataset.iszf;
    console.log(cardiszf)
    var that = this;
    wx.chooseImage({
      count: 1, // 默认9
      sizeType: ['compressed'], // 可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
      success: function (res) {
        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
        var tempFilePaths = res.tempFilePaths
        if (cardiszf == "true") {
          that.setData({
            cardImag: res.tempFilePaths
          });
          that.uploadImg(true, that.data.cardImag[0], 'face')
          // //上传图片
          // common._upload_file('/wx/contract/savepic', that.data.cardImag[0], 'file', { attribute: 'face' },
          //   //成功
          //   function (res) {
          //     if (res.success) {
          //       console.log(res.data.imgUrl)
          //       that.setData({
          //         cardImagUrl: res.data.imgUrl,
          //       })
          //     }
          //   });
        } else {
          that.setData({
            cardBack: res.tempFilePaths
          });
          that.uploadImg(false, that.data.cardBack[0], 'back')
          // // 上传身份证背面
          // common._upload_file('/wx/contract/savepic', that.data.cardBack[0], 'file', { attribute: 'back' },
          //   //成功
          //   function (res) {
          //     if (res.success) {
          //       console.log(res.data.imgUrl)
          //       that.setData({
          //         cardBackUrl: res.data.imgUrl,
          //       })
          //       that.submitBnt();
          //     }
          //   });

        }
        // that.compressedImg(cardiszf, res.tempFilePaths[0]);


      }
    })

  },
  uploadImg: function (iszf, imgpatg, attribute) {
    var that = this;
    // wx.showModal({
    //   title: '',
    //   content: imgpatg,
    // })
    common._upload_file('/wx/contract/savepic', imgpatg, 'file', { attribute: attribute },
      //成功
      function (res) {
        if (res.success) {
          if (iszf) {
            that.setData({
              cardImagUrl: res.data.imgUrl,

            })
          } else {
            that.setData({
              cardBackUrl: res.data.imgUrl,
            })
          }

        } else {
          if (iszf) {
            that.setData({
              cardImagUrl: '',
              cardImag: '',//身份证正面图片路径

            })
          } else {
            that.setData({
              cardBackUrl: '',
              cardBack: '',
            })
          }
        }
      });
  },



  //删除身份证正面
  deleteFace: function () {
    this.setData({
      cardImag: []
    });
  },
  //删除身份证反面
  deleteBack: function () {
    this.setData({
      cardBack: []
    });
  },
  //点击添加费用
  addFeeClick: function (e) {
    this.data.feeItemType = e.currentTarget.dataset.key;
    console.log(this.data.feeItemType)
    wx.navigateTo({
      url: '../fyx/fyx?key=' + this.data.feeItemType,
    })
  },
  //费用输入
  feeInput: function (e) {
    var value = e.detail.value;
    var indx = e.currentTarget.dataset.index;
    this.data.feeList[indx].unitCost = value;
    console.log(this.data.feeList[indx])
    this.totalFun();
  },



  //初始读数输入
  nowNumInput: function (e) {
    var value = e.detail.value;
    // var indx = e.currentTarget.dataset.index;
    this.data.WEItem.nowNum = value == '' ? 0 : value;
  },
  //水电单价输入
  WEItemChange: function (e) {
    var value = e.detail.value;
    // var indx = e.currentTarget.dataset.index;
    this.data.WEItem.unitCost = value == '' ? 0 : value;
  },
  //确认
  confirm: function () {
    this.data.feeList[this.data.WEItemIndex] = this.data.WEItem;
    this.setData({
      feeList: this.data.feeList,
      WEmodal: true,
    })
    this.totalFun();
  },
  //取消
  cancel: function () {
    this.setData({
      WEmodal: true,
    })
  },
  WEFeeItemClick: function (e) {
    var indx = e.currentTarget.dataset.index;
    this.setData({
      WEItemIndex: indx,
      WEmodal: false,
      WEItem: this.data.feeList[indx]
    })
  },
  // 总计
  totalFun: function () {
    var arr = this.data.feeList;
    var arry = this.data.feeListy;
    var n = Number(this.data.payTypeList[this.data.paytypeindex].key)
    var sum = 0;
    //费用项
    for (var i in arr) {
      if (arr[i].chargeType == 1) {
        if (arr[i].unitCost && arr[i].unitCost > 0) {
          sum = sum + Number(arr[i].unitCost)
        }
      }
    }
    var fwyj = 0;
    //费用项
    for (var i in arry) {
      if (Number(arry[i].itemKey) == 1) {
        fwyj = Number(arry[i].unitCost);
      } else {
        if (arry[i].unitCost && arry[i].unitCost > 0) {
          sum = sum + Number(arry[i].unitCost)
        }
      }
    }

    //每月租金
    // sum = sum + Number(this.data.monthlyfee);
    //付款方式 payTypeList: [],//付款方式列表
    // paytypeindex: 0,//付款方式下标
    // console.log(fwyj)
    // console.log(this.data.payTypeList[this.data.paytypeindex].key);

    switch (n) {
      case 1:
        sum = sum + (Number(this.data.monthlyfee) * 1)
        break;
      case 2:
        sum = sum + (Number(this.data.monthlyfee) * 2)
        break;
      case 3:
        sum = sum + (Number(this.data.monthlyfee) * 3)
        break;
      case 4:
        // sum = sum + (Number(this.data.monthlyfee) * 2) + (fwyj * 2);
        sum = sum + (Number(this.data.monthlyfee) * 2)
        break;
      case 5:
        // sum = sum + (Number(this.data.monthlyfee) * 3) + (fwyj * 2);
        sum = sum + (Number(this.data.monthlyfee) * 3)
        break;
    }
    //加上押金
    sum = sum + fwyj;
    this.setData({
      total: sum,
    })

  },
  //计算押金
  countYj: function () {
    var n = Number(this.data.payTypeList[this.data.paytypeindex].key)
    var arry = this.data.feeListy;
    var index = -1;
    //费用项
    for (var i in arry) {
      if (Number(arry[i].itemKey) == 1) {
        // index = Number(arry[i].unitCost);
        index = i;
      }
    }
    if (i == -1) {
      return;
    }
    console.log('n')
    console.log(n)
    switch (n) {
      case 1:
        arry[index].unitCost = Number(this.data.monthlyfee) * 1
        break;
      case 2:
        arry[index].unitCost = Number(this.data.monthlyfee) * 1
        break;
      case 3:
        arry[index].unitCost = Number(this.data.monthlyfee) * 1
        break;
      case 4:
        arry[index].unitCost = Number(this.data.monthlyfee) * 2
        break;
      case 5:
        arry[index].unitCost = Number(this.data.monthlyfee) * 2
        break;
    }
    console.log(arry)
    this.setData({
      feeListy: arry,
    })
  },


  //押金输入
  feeyInput: function (e) {
    var value = e.detail.value;
    var indx = e.currentTarget.dataset.index;
    this.data.feeListy[indx].unitCost = value;
    this.setData({
      feeListy: this.data.feeListy
    })
    console.log(this.data.feeListy)
    this.totalFun();
  },

  //去签名
  toSignature: function () {
    wx.navigateTo({
      url: '../signature/signature',
    })
  },

  checkboxChange: function (e) {
    var b = !this.data.checked;
    this.setData({
      checked: b,
    })
  },
  //用户名字输入
  userNameInput: function (e) {
    this.data.cardInfo.name = e.detail.value;
    // var userData = this.data.cardInfo;
    // console.log(userData)
    // this.setData({
    //   cardInfo: userData,
    // })
  },
  //每月租金输入
  monthlyfeeInput: function (e) {
    this.setData({
      monthlyfee: e.detail.value,
    })
    this.countYj();
    this.totalFun();
  },
  //性别选择
  sexChange: function (e) {
    this.setData({
      sexIndex: e.detail.value,
    })
  },
  //付款方式选择
  payTypeChabge: function (e) {
    this.setData({
      paytypeindex: e.detail.value,
    })
    this.countYj();
    this.totalFun();
  },
  //房源选择选择
  houseChange: function (e) {
    if (this.houseIndex != e.detail.value) {
      this.getRoomList(this.data.houseList[e.detail.value].id)
    }
    this.setData({
      houseIndex: e.detail.value,
    })
  },
  //房间选择选择
  memberChabge: function (e) {
    this.setData({
      roomIndex: e.detail.value,
    })
    that.setData({
      monthlyfee: rooms[that.data.roomIndex].monthlyfee,
    })
    this.countYj();
  },

  //备注输入
  remarkInput: function (e) {
    this.setData({
      remark: e.detail.value,
    })
  },
  //备注输入
  idcardInput: function (e) {
    this.setData({
      idcardNum: e.detail.value,
    })
  },
  remarkInput: function (e) {
    this.setData({
      remark: e.detail.value,
    })
  },
  roomPayType:function(){
    wx.showModal({
      title: '提示',
      content: '付款方式需要到房间才能进行修改',
      showCancel:false,
    })
  },

  //要提交的数据
  submitData: function () {

    // id:,//合同ID(修改时提交)
    var data = this.data;
    var datas = {
      sex: data.sexList[data.sexIndex].sex,//租户性别(0--女 1--男)
      starttime: data.startTime,//合同开始时间
      monthlyfee: data.monthlyfee,//月租金
      chargemode: data.payTypeList[data.paytypeindex].key,//收费方式
      remark: data.remark ? data.remark : '',//备注
      memberId: data.cardInfo.id ? data.cardInfo.id : '',//租户ID
      mobile: data.phone,//租户手机号
      username: data.cardInfo.name,//租户姓名
      endtime: data.endTime,//合同截止时间
      gifts: data.feeListy,//押金列表
      roomId: data.roomList[data.roomIndex].id,//房间ID
      idNumber: data.idcardNum ? data.idcardNum : '',//身份证号码
      items: data.feeList,//固定费用列表
      // idCardFace: data.cardImagUrl,//身份证正面图片路径
      // idCardBack: data.cardBackUrl,//身份证反面图片路径
    }
    return datas;
  },

  submitBnt: function () {
    var that = this;
    this.uploadData();

  },

  //保存合同
  uploadData: function () {
    var data = this.data;
    if (data.cardInfo.name) {
    } else {
      wx.showToast({
        title: '租户姓名不能为空',
        image: '../../image/shibai.png'
      })
      return;
    }
    if (data.cardInfo.name == '') {
      wx.showToast({
        title: '租户姓名不能为空',
        image: '../../image/shibai.png'
      })
      return;
    }
    if (data.phone) {
    } else {
      wx.showToast({
        title: '联系电话不能为空',
        image: '../../image/shibai.png'
      })
      return;
    }
    if (data.phone == '') {
      wx.showToast({
        title: '联系电话不能为空',
        image: '../../image/shibai.png'
      })
      return;
    }
    if (!common.checkMobile(data.phone)) {
      wx.showToast({
        title: '手机号码错误',
        image: '../../image/shibai.png'
      })
      return;
    }
    // if (this.data.idcardNum && this.data.idcardNum.length>1 ){
    //   if (!common.IdentityCodeValid(this.data.idcardNum)) {
    //     wx.showToast({
    //       title: '身份证号码错误',
    //       image: '../../image/shibai.png'
    //     })
    //     return;
    //   }
    // }

    var daras = this.submitData();
    common._get('/wx/contract/save', daras,
      //成功
      function (res) {
        console.log(res.data);
        //手机获取信息是否成功
        if (res.data.success) {
          app.setRefresh();
          wx.setStorageSync('modifyRoom', 'modifyRoom');
          //成功添加入住
          wx.setStorageSync('addContract', "addContract")
          wx.showModal({
            title: '提示',
            content: '已经成功保存入住',
            showCancel: false,
            success: function (resm) {
              if (resm.confirm) {
                wx.redirectTo({
                  url: '../receiptDetails/receiptDetails?chargeid=' + res.data.data.chargeId + '&add_contract=yes',
                })
              }
            }
          })
        }
      });


  },
  //删除费用项
  deleteFeeItem: function (e) {
    var that = this;
    var indx = e.target.dataset.index;
    wx.showModal({
      title: '删除提示！',
      content: '确定要删除' + this.data.feeList[indx].itemName,
      success: function (res) {
        if (res.confirm) {
          that.data.feeList.splice(indx, 1);
          var fee = that.data.feeList;
          that.setData({
            feeList: fee
          })
          that.totalFun();
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
    this.totalFun();
  },
  //删除押金费用项
  deleteYjItem: function (e) {
    var that = this;
    var indx = e.target.dataset.index;
    wx.showModal({
      title: '删除提示！',
      content: '确定要删除' + this.data.feeListy[indx].itemName,
      success: function (res) {
        if (res.confirm) {
          that.data.feeListy.splice(indx, 1);
          var fee = that.data.feeListy;
          that.setData({
            feeListy: fee
          })
          that.totalFun();
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
    this.totalFun();
  },

  //显示签名 弃用

  showSignature: function () {
    var urls = [];
    urls.push(this.data.signatureUrl);
    console.log(urls);
    wx.previewImage({
      current: 0, // 当前显示图片的http链接
      urls: urls // 需要预览的图片http链接列表
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (options.room_id) {
      this.setData({
        roomId: options.room_id
      })
    }

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    this.initData();
    this.setMonth();
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    //获取费用项
    var fee = wx.getStorageSync("feeList");
    wx.removeStorageSync("feeList");
    if (fee) {
      if (this.data.feeItemType == "CHARGEITEM") {
        var fees = this.data.feeList
        //匹配是否有相同并删除
        fee = app.feeRepeat(fee, fees)
        // for (var i in fee) {
        //   for (var j in fees) {
        //     if (fee[i].itemKey == fees[j].itemKey){
        //       fee.splice(i, 1);
        //     }
        //   }
        // }
        fees.push.apply(fees, fee);
        this.setData({
          feeList: fees,
        })
      } else {
        var fees = this.data.feeListy
        //匹配是否有相同并删除
        fee = app.feeRepeat(fee, fees);
        // for (var i in fee) {
        //   for (var j in fees) {
        //     if (fee[i].itemKey == fees[j].itemKey) {
        //       fee.splice(i, 1);
        //     }
        //   }
        // }
        fees.push.apply(fees, fee);
        this.setData({
          feeListy: fees,
        })
      }
    }
    //获取签名图片
    var sUrl = wx.getStorageSync("signatureUrl");
    wx.removeStorageSync("signatureUrl");
    if (sUrl) {
      this.setData({
        signatureUrl: sUrl
      })
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})